data {
  int n_years_count;
  
  int n_4_v2exdfdshs;
  int items_4_v2exdfdshs[n_4_v2exdfdshs];
  int years_count_ind_4_v2exdfdshs[n_4_v2exdfdshs];
  
  int n_5_v2exdfvths;
  int items_5_v2exdfvths[n_5_v2exdfvths];
  int years_count_ind_5_v2exdfvths[n_5_v2exdfvths];
  
  int n_3_v2exdfpphs;
  int items_3_v2exdfpphs[n_3_v2exdfpphs];
  int years_count_ind_3_v2exdfpphs[n_3_v2exdfpphs];
  
  int n_5_v2lginvstp;
  int items_5_v2lginvstp[n_5_v2lginvstp];
  int years_count_ind_5_v2lginvstp[n_5_v2lginvstp];
  
  int n_3_v2lgoppart;
  int items_3_v2lgoppart[n_3_v2lgoppart];
  int years_count_ind_3_v2lgoppart[n_3_v2lgoppart];
  
  int n_2_v2lgfunds;
  int items_2_v2lgfunds[n_2_v2lgfunds];
  int years_count_ind_2_v2lgfunds[n_2_v2lgfunds];
  
  int n_4_v2lgcomslo;
  int items_4_v2lgcomslo[n_4_v2lgcomslo];
  int years_count_ind_4_v2lgcomslo[n_4_v2lgcomslo];
  
  int n_2_v2lgintbup;
  int items_2_v2lgintbup[n_2_v2lgintbup];
  int years_count_ind_2_v2lgintbup[n_2_v2lgintbup];
  
  int n_2_v2lgintblo;
  int items_2_v2lgintblo[n_2_v2lgintblo];
  int years_count_ind_2_v2lgintblo[n_2_v2lgintblo];

  int n_2_v2lgqstexp;
  int items_2_v2lgqstexp[n_2_v2lgqstexp];
  int years_count_ind_2_v2lgqstexp[n_2_v2lgqstexp];
  
  
}

parameters {		
 ordered[3] c_n_4_v2exdfdshs;
 ordered[4] c_n_5_v2exdfvths;
 ordered[2] c_n_3_v2exdfpphs;
 ordered[4] c_n_5_v2lginvstp;
 ordered[2] c_n_3_v2lgoppart;
 ordered[1] c_n_2_v2lgfunds;
 ordered[3] c_n_4_v2lgcomslo;
 ordered[1] c_n_2_v2lgintbup;
 ordered[1] c_n_2_v2lgintblo;
 ordered[1] c_n_2_v2lgqstexp;
 
  
  vector[n_years_count] thetas;

  real<lower=0> beta[10];

}




model{
  
  thetas ~ normal(0, 1); 


   for(ii in 1:n_4_v2exdfdshs){
	items_4_v2exdfdshs[ii] ~ ordered_logistic(beta[1] * thetas[years_count_ind_4_v2exdfdshs[ii]], c_n_4_v2exdfdshs);
  }

for(ii in 1:n_5_v2exdfvths){
	items_5_v2exdfvths[ii] ~ ordered_logistic(beta[2] * thetas[years_count_ind_5_v2exdfvths[ii]], c_n_5_v2exdfvths);
  }

for(ii in 1:n_3_v2exdfpphs){
	items_3_v2exdfpphs[ii] ~ ordered_logistic(beta[3] * thetas[years_count_ind_3_v2exdfpphs[ii]], c_n_3_v2exdfpphs);
  }

for(ii in 1:n_5_v2lginvstp){
	items_5_v2lginvstp[ii] ~ ordered_logistic(beta[4] * thetas[years_count_ind_5_v2lginvstp[ii]], c_n_5_v2lginvstp);
  }

for(ii in 1:n_3_v2lgoppart){
	items_3_v2lgoppart[ii] ~ ordered_logistic(beta[5] * thetas[years_count_ind_3_v2lgoppart[ii]], c_n_3_v2lgoppart);
  }

for(ii in 1:n_2_v2lgfunds){
	items_2_v2lgfunds[ii] ~ ordered_logistic(beta[6] * thetas[years_count_ind_2_v2lgfunds[ii]], c_n_2_v2lgfunds);
  }

for(ii in 1:n_4_v2lgcomslo){
	items_4_v2lgcomslo[ii] ~ ordered_logistic(beta[7] * thetas[years_count_ind_4_v2lgcomslo[ii]], c_n_4_v2lgcomslo);
  }

for(ii in 1:n_2_v2lgintbup){
	items_2_v2lgintbup[ii] ~ ordered_logistic(beta[8] * thetas[years_count_ind_2_v2lgintbup[ii]], c_n_2_v2lgintbup);
  }

for(ii in 1:n_2_v2lgintblo){
	items_2_v2lgintblo[ii] ~ ordered_logistic(beta[9] * thetas[years_count_ind_2_v2lgintblo[ii]], c_n_2_v2lgintblo);
  }

for(ii in 1:n_2_v2lgqstexp){
	items_2_v2lgqstexp[ii] ~ ordered_logistic(beta[10] * thetas[years_count_ind_2_v2lgqstexp[ii]], c_n_2_v2lgqstexp);
  }


 beta ~ normal(0, 3);
}



generated quantities { 
  vector[n_4_v2exdfdshs] y_hat_n_4_v2exdfdshs;
  vector[n_5_v2exdfvths] y_hat_n_5_v2exdfvths;
  vector[n_3_v2exdfpphs] y_hat_n_3_v2exdfpphs;
  vector[n_5_v2lginvstp] y_hat_n_5_v2lginvstp;
  vector[n_3_v2lgoppart] y_hat_n_3_v2lgoppart;
  vector[n_2_v2lgfunds]  y_hat_n_2_v2lgfunds;
  vector[n_4_v2lgcomslo] y_hat_n_4_v2lgcomslo;
  vector[n_2_v2lgintbup] y_hat_n_2_v2lgintbup;
  vector[n_2_v2lgintblo] y_hat_n_2_v2lgintblo;
  vector[n_2_v2lgqstexp] y_hat_n_2_v2lgqstexp;
  vector[n_4_v2exdfdshs+n_5_v2exdfvths+n_3_v2exdfpphs+n_5_v2lginvstp+n_3_v2lgoppart+
n_2_v2lgfunds+n_4_v2lgcomslo+n_2_v2lgintbup+n_2_v2lgintblo+n_2_v2lgqstexp] log_lik;


  
  
  for(ii in 1:n_4_v2exdfdshs){
	y_hat_n_4_v2exdfdshs[ii] = ordered_logistic_rng(beta[1] * thetas[years_count_ind_4_v2exdfdshs[ii]], c_n_4_v2exdfdshs);
	log_lik[ii] = ordered_logistic_lpmf(items_4_v2exdfdshs[ii] | beta[1] * thetas[years_count_ind_4_v2exdfdshs[ii]], c_n_4_v2exdfdshs);
  }


  for(ii in 1:n_5_v2exdfvths){
	y_hat_n_5_v2exdfvths[ii] = ordered_logistic_rng(beta[2] * thetas[years_count_ind_5_v2exdfvths[ii]], c_n_5_v2exdfvths);
	log_lik[n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_5_v2exdfvths[ii] | beta[2] * thetas[years_count_ind_5_v2exdfvths[ii]], c_n_5_v2exdfvths);
  }
  
  for(ii in 1:n_3_v2exdfpphs){
	y_hat_n_3_v2exdfpphs[ii] = ordered_logistic_rng(beta[3] * thetas[years_count_ind_3_v2exdfpphs[ii]], c_n_3_v2exdfpphs);
	log_lik[n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_3_v2exdfpphs[ii] | beta[3] * thetas[years_count_ind_3_v2exdfpphs[ii]], c_n_3_v2exdfpphs);
  }

  for(ii in 1:n_5_v2lginvstp){
	y_hat_n_5_v2lginvstp[ii] = ordered_logistic_rng(beta[4] * thetas[years_count_ind_5_v2lginvstp[ii]], c_n_5_v2lginvstp);
	log_lik[n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_5_v2lginvstp[ii] | beta[4] * thetas[years_count_ind_5_v2lginvstp[ii]], c_n_5_v2lginvstp);
  }
  
  for(ii in 1:n_3_v2lgoppart){
	y_hat_n_3_v2lgoppart[ii] = ordered_logistic_rng(beta[5] * thetas[years_count_ind_3_v2lgoppart[ii]], c_n_3_v2lgoppart);
	log_lik[n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_3_v2lgoppart[ii] | beta[5] * thetas[years_count_ind_3_v2lgoppart[ii]], c_n_3_v2lgoppart);
  }
  
  for(ii in 1:n_2_v2lgfunds){
	y_hat_n_2_v2lgfunds[ii] = ordered_logistic_rng(beta[6] * thetas[years_count_ind_2_v2lgfunds[ii]], c_n_2_v2lgfunds);
	log_lik[n_3_v2lgoppart+n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_2_v2lgfunds[ii] | beta[6] * thetas[years_count_ind_2_v2lgfunds[ii]], c_n_2_v2lgfunds);
  }

  for(ii in 1:n_4_v2lgcomslo){
	y_hat_n_4_v2lgcomslo[ii] = ordered_logistic_rng(beta[7] * thetas[years_count_ind_4_v2lgcomslo[ii]], c_n_4_v2lgcomslo);
	log_lik[n_2_v2lgfunds+n_3_v2lgoppart+n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_4_v2lgcomslo[ii] | beta[7] * thetas[years_count_ind_4_v2lgcomslo[ii]], c_n_4_v2lgcomslo);
  }

  for(ii in 1:n_2_v2lgintbup){
	y_hat_n_2_v2lgintbup[ii] = ordered_logistic_rng(beta[8] * thetas[years_count_ind_2_v2lgintbup[ii]], c_n_2_v2lgintbup);
	log_lik[n_4_v2lgcomslo+n_2_v2lgfunds+n_3_v2lgoppart+n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_2_v2lgintbup[ii] | beta[8] *  thetas[years_count_ind_2_v2lgintbup[ii]],  c_n_2_v2lgintbup);
  }

for(ii in 1:n_2_v2lgintblo){
	y_hat_n_2_v2lgintblo[ii] = ordered_logistic_rng(beta[9] * thetas[years_count_ind_2_v2lgintblo[ii]], c_n_2_v2lgintblo);
	log_lik[n_2_v2lgintbup+n_4_v2lgcomslo+n_2_v2lgfunds+n_3_v2lgoppart+n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_2_v2lgintblo[ii] | beta[9] *  thetas[years_count_ind_2_v2lgintblo[ii]],  c_n_2_v2lgintblo);
  }


for(ii in 1:n_2_v2lgqstexp){
	y_hat_n_2_v2lgqstexp[ii] = ordered_logistic_rng(beta[10] * thetas[years_count_ind_2_v2lgqstexp[ii]], c_n_2_v2lgqstexp);
	log_lik[n_2_v2lgintblo+n_2_v2lgintbup+n_4_v2lgcomslo+n_2_v2lgfunds+n_3_v2lgoppart+n_5_v2lginvstp+n_3_v2exdfpphs+n_5_v2exdfvths+n_4_v2exdfdshs+ii] = ordered_logistic_lpmf(items_2_v2lgqstexp[ii] | beta[10] *  thetas[years_count_ind_2_v2lgqstexp[ii]],  c_n_2_v2lgqstexp);
  }

}



